import request from '@/utils/request'

// 获取商品分类下的参数
export function getAttrs(params) {
  return request({
    url: '/attrs',
    method: 'get',
    params
  })
}

// 新增商品分类下的参数
export function addAttrs(data) {
  return request({
    url: '/goods/attr/',
    method: 'post',
    data
  })
}

// 修改商品分类下的参数值
export function editAttrs(id, data) {
  return request({
    url: `/goods/attr/${id}/`,
    method: 'put',
    data
  })
}

// 删除商品分类下的参数
export function delAttrs(id) {
  return request({
    url: `/goods/attr/${id}/`,
    method: 'delete'
  })
}

// 图片上传
export function uploadImg(data) {
  const formData = new FormData()
  formData.append('file', data)
  return request({
    url: '/goods/goods/good_image/',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: formData
  })
}

